/*
 * Copyright (c) 2011 Sapienza University of Rome.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * - Redistributions of source code must retain the above copyright
 *   notice, this list of conditions and the following disclaimer.
 * - Redistributions in binary form must reproduce the above copyright
 *   notice, this list of conditions and the following disclaimer in the
 *   documentation and/or other materials provided with the
 *   distribution.
 * - Neither the name of the Sapienza University of Rome nor the names of
 *   its contributors may be used to endorse or promote products derived
 *   from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL SAPIENZA
 * UNIVERSITY OF ROME OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
 * OF THE POSSIBILITY OF SUCH DAMAGE.
 */
/**
 * @author Ugo Colesanti <colesanti@dis.uniroma1.it>
 * @version 1.01 (September 28, 2011)
 *
 */
#include "Application.h"
#ifndef TOSSIM
#include "StorageVolumes.h"
#endif
configuration TOSSIMNodeAppC {
	provides interface StdControl ;
}
implementation{
#ifndef TOSSIM
  components MainC ;
#endif
  components ManagerAppC as DISSense ;


    components NodeApplicationC as ApplicationC ;
    StdControl = ApplicationC ;

// Both apps ######################################################################################
components ActiveMessageC ;                         // AM layer
ApplicationC.RadioControl -> ActiveMessageC;
#ifdef NOLEDS
  components NoLedsC as LedsComp ;
#else
  components LedsC as LedsComp ;
#endif
  ApplicationC.Leds -> LedsComp;
#ifndef TOSSIM
  ApplicationC.Boot -> MainC;
#endif
  components new TimerMilliC() as Timer ;
  ApplicationC.Timer -> Timer ;
  ApplicationC.ManagerControl -> DISSense ;
  ApplicationC.DISSenseStatistics -> DISSense ; // stats to be printed with data.


// Enables StorageFlash logging ------------------------------------------
#ifdef LOG
  components FlashLogC as FlashLogComp;
  components new LogStorageC(VOLUME_LOGTEST,TRUE) as Flash ;
  components CC2420ActiveMessageC as LplRadio ;

  components new AMSenderC(AM_FLASHLOGMSG) as FlashLogSender ;
  components new AMReceiverC(AM_FLASHLOGMSG) as FlashLogReceiver;

  components new TimerMilliC() as FlushInterleavingTimer ;
  FlashLogComp.LogRead -> Flash ;
  FlashLogComp.LogWrite -> Flash ;
  FlashLogComp.Receive -> FlashLogReceiver ;
  FlashLogComp.Send -> FlashLogSender ;
  FlashLogComp.PacketAcknowledgements -> LplRadio ;
  FlashLogComp.FlushInterleavingTimer -> FlushInterleavingTimer ;
  FlashLogComp.Leds -> LedsComp ;
#else
  components DummyLogC as FlashLogComp ;
#endif
  ApplicationC.FlashLog -> FlashLogComp ;
// ------------------------------------------------------------------------
// #################################################################################################


    ApplicationC.Receive -> DISSense ; // should be removed

  // Node specific ###################################################################################
    ApplicationC.Send -> DISSense ;
    ApplicationC.DISSenseSampling -> DISSense ;
    // Enables readings from sensors ------------------------------------------

		#ifdef SERIAL
			#warning "********** SERIAL SENSOR - ENABLED ***********"
			components StrainSensorC as SerialSensor ;
		#else
			#warning "********** SERIAL SENSOR - DISABLED ***********"
			components new DummySensorC() as SerialSensor ;
		#endif
		#ifdef VOLTAGE
			#warning "********** VOLTAGE SENSOR - ENABLED ***********"
			components new Msp430InternalVoltageC() as VoltageSensor ;
	//    #elif defined(TEMPERATURE)
	//		#warning "********** TEMPERATURE SENSOR - ENABLED ***********"
	//        components new SensirionSht11C() as VoltageSensor ;
		#else
			#warning "********** VOLTAGE/TEMP SENSOR - DISABLED ***********"
			components new DummySensorC() as VoltageSensor ;
		#endif
			ApplicationC.ReadVoltage -> VoltageSensor ;
			ApplicationC.ReadSensor -> SerialSensor ;
		// --------------------------------------------------------------------------
	  // ################################################################################################

//################################ DEBUG ######################################
#ifdef DEBUGLOGGER
components DebugLoggerAppC as DebugLC;
#else
components DummyDebugC as DebugLC ;
#endif
ApplicationC.DebugLogger -> DebugLC ;



}
